<template>
  <Card :bordered="false" dis-hover>
<!--    <Button type="primary" icon="ios-log-out" @click="exportFile" class="export">导出</Button>-->
    <basic-table
      :columns="columns"
      :loading="tableLoading"
      :dataSource="tableData"
      :showTotal="false"
    >
    </basic-table>
  </Card>
</template>
<script>
import {ApiRequest, ApiRequestExportTable} from '@api/basePage';
import BasicTable from '@/components/skusTable';
import {isResponseSuccess} from "@/utils/bizUtils";

export default {
  components: {
    BasicTable
  },
  data() {
    return {
      columns: [
        {title: '序号', key: 'index', render: (h,params) => {
            return h('span', params.index + 1)
          }},
        {title: '未购买原因', key: 'reasonName'},
        {
          title: '反馈条目数', key: 'replyCount', render: (h, params) => {
            return h('a', {
              style: {
                marginRight: '5px'
              },
              on: {
                click: () => {
                  this.goHrefDetail(params)
                }
              }
            }, `${params.row.replyCount}条`)
          }
        }
      ],
      tableData: [],
      tableLoading: false,
    }
  },
  mounted() {
    this.getDataList()
  },
  methods: {
    goHrefDetail(e) {
      let query = {
        reasonValue: e.row.reasonValue,
        reasonCode: e.row.reasonCode,
        reasonName: e.row.reasonName
      }
      this.$router.push({
        name: 'notPurchaseReasonDetail',
        query
      })
    },
    getDataList() {
      ApiRequest('/modular/api/productReport/queryNotPurchasedReasonTotalReport', 'get', {}).then((res) => {
        // if (isResponseSuccess(res)) {
        if (res.code == '0') {
          this.tableData = res.data
        }
      }).catch(() => {

      });
    },
    exportFile() {
      ApiRequestExportTable( url, type, data, true ).then(res => {
        const blob = new Blob([res], {
          type: 'application/octet-stream'
        });
        var link = document.createElement('a');
        link.href = window.URL.createObjectURL(blob);
        link.download = '后台品类表.xlsx';
        link.click();
        window.URL.revokeObjectURL(blob); // 释放掉blob对象
      }).catch(err => {
        this.$Message.Message('导出失败');
      });
    }
  }
}
</script>
<style scoped>
.plTableBox{
  color: #515a6e !important;
}
.ivu-card-body{
  padding: 16px;
}
.export{
  margin-bottom: 10px;
}
</style>
